package cn.edu.scau.cmi.wujiaxian.adapter;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class AdapterOfObject implements SortStudentUtil{

	@Override
	public List<Student> sort(List<Student> studentList) {
		SortUtil sortUtil = new SortUtil();
		List<Integer> studentNumberList = studentList.stream()
				.map(student -> student.getSutdentNumber())
				.collect(Collectors.toList());
		studentNumberList = sortUtil.sortInt(studentNumberList);
		List<Student> list = new ArrayList<>(studentList.size());
		for (Integer studentNumber : studentNumberList) {
			for (Student student : studentList) {
				if (student.getSutdentNumber() == studentNumber) {
					list.add(student);
					break;
				}
			}
		}
		return list;
	}

}
